package br.ucb.sigplan.action.impl;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import br.ucb.sigplan.action.Action;
import br.ucb.sigplan.action.impl.service.CadastraConteudosTurmaService;
import br.ucb.sigplan.beans.Conteudo;
import br.ucb.sigplan.beans.Turma;
import br.ucb.sigplan.crud.ConteudoTurmaCrud;

public class AlteraConteudoTurmaAction implements Action {

	@Override
	public String execute(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		HttpSession session = req.getSession();
		Integer idTurma = (Integer) session.getAttribute("turma");
		Turma turma = new Turma(idTurma);
		List<Conteudo> conteudos = (List<Conteudo>) session.getAttribute("conteudosTurma");
		List<Conteudo> conteudosTurma = ConteudoTurmaCrud.findConteudoByTurma(idTurma);
		CadastraConteudosTurmaService.adicionaBanco(conteudos, conteudosTurma, turma);
		CadastraConteudosTurmaService.deleteBanco(conteudos, conteudosTurma, turma);
		return "abrirAlteraPlano.do";
	}

}
